package com.activities;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.app.TabActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TabHost;
import android.widget.TabWidget;

import com.Utility.GetEpackge;
import com.Utility.Utility;
import com.activities.group.TabBaseGroupActivity;
import com.activities.group.TabHomeGroupActivity;
import com.parser.Error_Report;
import com.parser.Parser_Soap;
import com.senditcertified.mail.Attachment;
import com.senditcertified.mail.Message;
import com.senditcertified.mail.R;
import com.senditcertified.mail.Video;
import com.senditcertified.mail.Voice;
import com.soap.call.Http_Soap_Call;

public class SecureActivity extends TabActivity {

	TabHost mTabHost;
	TabWidget mTabWidget;
	public EditText username, your_name, your_email, accesscode;
	public static GetEpackge getEpackge = null;
	public static String MSG_ID;
	ProgressDialog pd;

	public Activity getParentActivity() {
		return getParent();
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		View viewToLoad = LayoutInflater.from(this.getParent()).inflate(
				R.layout.securemain, null);
		this.setContentView(viewToLoad);
		username = (EditText) findViewById(R.id.username);
		your_name = (EditText) findViewById(R.id.your_name);
		your_email = (EditText) findViewById(R.id.your_email);
		accesscode = (EditText) findViewById(R.id.accesscode);
		getEpackge = (GetEpackge) this.getIntent().getExtras()
				.getSerializable("Message");
		MSG_ID = this.getIntent().getExtras().getString("MSG_ID");
		username.setText(getEpackge.getFile_create() + "");
		your_name.setText(getEpackge.getUsername() + "");
		your_email.setText(getEpackge.getSend_to() + "");
		accesscode.setText(getEpackge.getFile_desc() + "");

		mTabHost = getTabHost();
		TabHost.TabSpec spec;
		mTabWidget = mTabHost.getTabWidget();
		Resources res = getResources();
		Intent intent;
		intent = new Intent().setClass(this, Message.class);
		spec = mTabHost.newTabSpec(Message.class.getSimpleName())
				.setIndicator(getTabButton("Message", R.drawable.message))
				.setContent(intent);
		mTabHost.addTab(spec);
		// mTabWidget.getChildTabViewAt(0).setBackgroundColor(Color.TRANSPARENT);

		intent = new Intent().setClass(this, Attachment.class);
		spec = mTabHost
				.newTabSpec(Attachment.class.getSimpleName())
				.setIndicator(
						getTabButton("Attachment", R.drawable.attachments_tab))
				.setContent(intent);
		mTabHost.addTab(spec);
		// mTabWidget.getChildTabViewAt(1).setBackgroundColor(Color.TRANSPARENT);

		intent = new Intent().setClass(this, Video.class);
		spec = mTabHost.newTabSpec(Video.class.getSimpleName())
				.setIndicator(getTabButton("Video", R.drawable.video_tab))
				.setContent(intent);
		mTabHost.addTab(spec);

		// mTabWidget.getChildTabViewAt(2).setBackgroundColor(Color.TRANSPARENT);
		intent = new Intent().setClass(this, Voice.class);
		spec = mTabHost.newTabSpec(Voice.class.getSimpleName())
				.setIndicator(getTabButton("Voice", R.drawable.voice_tab))
				.setContent(intent);
		mTabHost.addTab(spec);
		// mTabWidget.getChildTabViewAt(3).setBackgroundColor(Color.TRANSPARENT);
		/*
		 * intent = new Intent().setClass(this, Tab_Group_Other.class); spec =
		 * mTabHost .newTabSpec(Tab_Group_Other.class.getSimpleName())
		 * .setIndicator("", res.getDrawable(R.drawable.valut_tab_selector))
		 * .setContent(intent); mTabHost.addTab(spec);
		 * mTabWidget.getChildTabViewAt(4).setBackgroundColor(Color.BLACK);
		 * intent = new Intent().setClass(this, Tab_Group_Other.class); spec =
		 * mTabHost .newTabSpec(Tab_Group_Other.class.getSimpleName())
		 * .setIndicator("", res.getDrawable(R.drawable.setting_tab_selector))
		 * .setContent(intent); mTabHost.addTab(spec);
		 */

		mTabHost.setCurrentTab(0);
		// mTabWidget.getChildTabViewAt(5).setBackgroundColor(Color.BLACK);

		/*
		 * try {
		 * ((TabHome_Activity)((TabGroupActivity)getParent()).getParent()).
		 * getHomeTab().setOnClickListener(new OnClickListener() {
		 * 
		 * public void onClick(View v) {
		 * 
		 * try { //if( TabHome_Activity.isChild_Active){ onBackPressed();
		 * ((TabHome_Activity) ((TabGroupActivity) getParent())
		 * .getParent()).getTabHost() .setCurrentTab(0); //} } catch (Exception
		 * e) { // TODO Auto-generated catch block e.printStackTrace(); }
		 * 
		 * 
		 * 
		 * } }); } catch (Exception e) { // TODO Auto-generated catch block
		 * e.printStackTrace(); }
		 */

		try {
			((TabHomeGroupActivity) ((TabBaseGroupActivity) getParent())
					.getParent()).registerHomeTabClick(this);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private Button getTabButton(String btnName, int btnDrawable) {
		Button btn = new Button(this);
		btn.setText(btnName);
		btn.setBackgroundResource(R.drawable.tab_button_style);
		// btn.setBackgroundColor(Color.TRANSPARENT);
		// btn.setTextColor(Color.WHITE);

		btn.setPadding(10, 10, 10, 10);
		btn.setTextSize(12);
		btn.setTextColor(Color.WHITE);
		return btn;
	}

}
